/**
 * @description 给层数，求三角的二维数组
 * @param {number} numRows
 * @return {number[][]}
 */
var generate = function (numRows) {
    if (numRows === 1) return [[1]];
    if (numRows === 2) return [[1], [1, 1]];
    let result = [[1], [1, 1]];
    for (let i = 2; i < numRows; i++) {
        result.push([1])
        for (let j = 0; j <= result[i - 1].length - 2; j++)
            result[i].push(result[i - 1][j] + result[i - 1][j + 1])
        result[i].push(1)
    }
    return result;
};